using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Ball : MonoBehaviour
{
    [Header("References")]
    [SerializeField] Rigidbody rb;

    [Header("Attributes")]
    [SerializeField] float bounceForce;
    [SerializeField] float wallForce;
    private void OnCollisionEnter(Collision collision)
    {
        AudioManager.instance.PlaySFX(AudioManager.instance.ballHit);

        if (collision.gameObject.CompareTag("Person") || collision.gameObject.CompareTag("Player"))
        {
            rb.AddForce((collision.contacts[0].normal + Vector3.up).normalized * bounceForce * collision.gameObject.GetComponent<Rigidbody>().velocity.magnitude, ForceMode.Impulse);
        }
        /*else if(collision.gameObject.CompareTag("Wall"))
        {
            rb.AddForce((collision.contacts[0].normal + Vector3.up).normalized * wallForce, ForceMode.Impulse);
        }*/
    }
}
